<?php

class AdminRssIndexController extends AdminIndexController
{
    public function prepare()
    {
        $page = Env::request('page', 1);
        
        $id = Env::get('id');
        $url = Env::get('url');
        $status = Env::get('status');
        
        if ($status == -1) {
            $status = null;
        }
        
        $filter = array();
        if ($id) {
            $filter['id'] = $id;
        }
        if ($url) {
            $filter['url'] = $url;
        }
        
        $order_field = Env::get('order_field', 'date_added');
        $order_by = Env::get('order_by', 'DESC');
        
        $order = array(
            'field' => $order_field,
            'by' => $order_by
        );
        
        $rss_model = new RssModel();
        
        $list = $rss_model->getList($page, RssModel::ADMIN_RSS_ON_PAGE, $status, $filter, $order);
        
        $Pager = new Pager($rss_model->getTotalCount(), $page, RssModel::ADMIN_RSS_ON_PAGE);
        
        $this->view->assign('pager', $Pager);
        $this->view->assign('list', $list);
    }
}